package com.wtwd.device.controller;

import com.google.inject.internal.cglib.proxy.$FixedValue;
import com.wtwd.device.model.entity.AlarmHealth;
import com.wtwd.device.model.entity.BloodOxygenList;
import com.wtwd.device.model.vo.RespEntity;
import com.wtwd.device.service.AlarmHealthService;
import com.wtwd.device.util.DateUtils;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.DateFormat;
import java.util.Date;
import java.util.List;

/**
 * 告警记录
 */
@Api(tags = "告警记录")
@RestController
@RequestMapping("/alarm-record")
public class AlarmRecordController {
    private static final Logger logger = LoggerFactory.getLogger(AlarmRecordController.class);


    @Autowired
    private AlarmHealthService alarmHealthService;
    /**
     * 分页获取告警记录
     * @param currentPage
     * @param pageSize

     * @return
     */
    @ApiOperation(value = "分页获取告警记录", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页", required = true, dataType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataType = "int"),
            @ApiImplicitParam(name = "date", value = "日期格式yyyyMMdd，不填默认当天", dataType = "String")
    })
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = AlarmHealth.class)
    })
    @GetMapping("/getAlarmRecordByPageAndDate")
    public RespEntity getAlarmRecordList(@RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,
                                         @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize,
                                         @RequestParam(value = "date",defaultValue = "")String date) {
        logger.info("getAlarmRecordList param" + currentPage,pageSize);
        if(date == null || date.equals("")){
            date = DateUtils.getDateStr(System.currentTimeMillis(),DateUtils.dateFormat18);
        }
        List<AlarmHealth> alarmRecordList = alarmHealthService.getAlarmRecordList(currentPage, pageSize,date);
        return RespEntity.success(alarmRecordList);
    }
}
